package com.liming.cartype.webapp.wicket.page;


import com.liming.cartype.api.persistence.impl.ParameterBeanImpl;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.RepeatingView;

/**
 * Created by Administrator on 14-5-4.
 */
public class ParameterTable extends Panel {

    final RepeatingView parameterItemView = new RepeatingView("parameterItemView");
    public ParameterTable(String id,ParameterBeanImpl parameterBean){
        super(id);

        //绑定A标签collapse
        Link collapse = new Link("collapse"){
            @Override
            public void onClick() {

            }
        };
        collapse.add(new AttributeModifier("href", "#collapse_"+id));

        //绑定parameterTableName
        Label parameterTableName = new Label("parameterTableName",parameterBean.getName());
        collapse.add(parameterTableName);
        add(collapse);

        //绑定参数项容器
        WebMarkupContainer collapseDiv = new WebMarkupContainer("collapseDiv");
        collapseDiv.add(new AttributeModifier("id", "collapse_"+id));
        add(collapseDiv);

        //新增参数项的表单
        AddParameterItemForm addParameterItemForm = new AddParameterItemForm(parameterItemView.newChildId(),parameterBean);
        parameterItemView.add(addParameterItemForm);
        collapseDiv.add(parameterItemView);

    }
}
